﻿[#include "../include/html_header.html"/]
<script type="text/javascript">
    function g(o) {
        return document.getElementById(o);
    }
    function checkType(status) {
        if (status == 0) {
            $("#status").attr("value", '');
        } else {
            $("#status").attr("value", status);
        }
        $("#search-form").submit();
    }


    function addCart(orderId) {
        $("#orderId").val(orderId);
        $("#search-form").attr("action", "${base}/cart/add_orderItem1.htm");
        $("#search-form").submit();
    }

    function payOrderAgain(orderId) {
        $("#orderId").val(orderId);
        $("#search-form").attr("action", "${base}/order/order_payAgain.htm");
        $("#search-form").submit();
    }

    function deleteOrder(orderId) {
        $.post('${base}/order/deleteOrder.htm', {
            'orderId': orderId
        }, function (data) {
            if (data.success) {
                location.reload();
            }
        }, 'json');
    }

    function abolishOrder(orderId) {
        $.post('${base}/order/abolishOrder.htm', {
            'orderId': orderId
        }, function (data) {
            if (data.success) {
                location.reload();
            }
        }, 'json');
    }


    function accomplishOrder(orderId) {
        $.post('${base}/order/accomplishOrder.htm', {
            'orderId': orderId
        }, function (data) {
            if (data.success) {
                location.reload();
            }
        }, 'json');
    }

    function showHide(pd) {
        if (pd == 0) {
            $("#J_MoreControl").hide();
            $("#moreFilter").show();
            $("#lessFilter").hide();
        } else {
            $("#J_MoreControl").show();
            $("#moreFilter").hide();
            $("#lessFilter").show();
        }
    }
</script>
<script src="${base}/thirdparty/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
</head>
<body>
[#include "../include/html_header_top.html"/]

<div class="am-container">
<div class="am-cf admin-main">
<!-- sidebar start -->
    [#include "member_nav.html"/]
<!-- sidebar end -->


    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">我的订单</strong></div>
        </div>
       <div class="am-u-sm-12 am-u-sm-centered">

        <form action="myorder.htm" method="post" class="am-form" id="search-form">
            <input type="hidden" id="status" name="status" [#if status??] value="${status}"[#else] value=""[/#if]/>
            <input type="hidden" id="orderId" name="orderId"/>
            <label>订单编号：</label>
            <input id="code" type="text" maxlength="30" value="" name="code" size="50" style="width:150px;display: inline;"/>

           <span>
           		[#if startTime??||endTime??||userName??||paymentId??||startOrderTotal??||endOrderTotal??||shippingId??]
            	<a class="less-filter" id="lessFilter" href="javascript:void(0);" onclick="showHide(0);">精简筛选条件</a>
            	<a class="more-filter" id="moreFilter" href="javascript:void(0);" onclick="showHide(1);"
                   style="display:none;">更多筛选条件</a>
           		[#else]
            	<a class="more-filter" id="moreFilter" href="javascript:void(0);" onclick="showHide(1);">更多筛选条件</a>
           		<a class="less-filter" id="lessFilter" href="javascript:void(0);" onclick="showHide(0);"
                   style="display:none;">精简筛选条件</a>
           		[/#if]
          </span>
            <div id="J_MoreControl" class="search-filter" [#if !(startTime??||endTime??||userName??||paymentId??||startOrderTotal??||endOrderTotal??||shippingId??)]style="display:none;"[/#if]>
            <table>
                <tr>
                    <td>下单时间:</td>
                    <td>  <input type="text" name="startTime" value="${startTime!}"
                                               onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width:100px;display:inline;" size="10"/>
                        到
                        <input type="text" name="endTime" value="${endTime!}"
                               onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width:100px;display:inline;" size="10"/>
                    </td>


                    <td>
                        收货人：
                    </td>
                    <td>
                        <input id="userName" type="text" name="userName" value="${userName!}" size="15"/>
                    </td>
                </tr>
               <tr>
                   <td>
                       支付方式：
                   </td>
                   <td>
                       <select id="paymentId" name="paymentId">
                           <option value="">--支付方式--</option>
                           [#list paymentList as payment]
                           <option value="${payment.id}"
                           [#if paymentId??] [#if
                           paymentId==payment.id]selected="selected"[/#if][/#if]>${payment.name!}</option>
                           [/#list]
                       </select>
                   </td>

                    <td>
                        订单金额:
                    </td>
                    <td>
                        <input type="text" name="startOrderTotal" value="${startOrderTotal!}" style="width:100px;display:inline;"/>至
                        <input type="text" name="endOrderTotal" value="${endOrderTotal!}" style="width:100px;display:inline;"/>
                    </td>
                </tr>
                <tr>
                    <td>
                        配送方式：
                    </td>
                    <td>
                        <select id="shippingId" name="shippingId">
                            <option value="">--配送方式--</option>
                            [#list shippingList as shipping]
                            <option value="${shipping.id}"
                            [#if shippingId??] [#if
                            shippingId==shipping.id]selected="selected"[/#if][/#if]>${shipping.name!}</option>
                            [/#list]
                        </select>
                    </td>

                </tr>
            </table>

         </div>
        <div class="am-u-sm-12 am-u-sm-centered">
        <button class="J_MakePoint am-btn am-btn-default" type="submit"><font color="#000000">搜索</font></button>
        </div>
        <div class="am-u-sm-12 am-u-sm-centered">
            <div class="am-tabs am-margin" data-am-tabs>
                <ul class="am-tabs-nav am-nav am-nav-tabs">

                    <li [#if !(status??)] class="am-active" [/#if]  > <a href="javascript:checkType(0)">全部[@order_page  status='' count='3'](${tag_pagination.totalCount})[/@order_page]</a></li>
                    <li  [#if status??&status==5] class="am-active" [/#if] > <a href="javascript:checkType(5)" >待支付[@order_page    status='5' count='3'](${tag_pagination.totalCount})[/@order_page]</a></li>
                    <li  [#if status??&status==6] class="am-active" [/#if] > <a href="javascript:checkType(6)" >待收货[@order_page status='6' count='3'](${tag_pagination.totalCount})[/@order_page]</a></li>
                    <li  [#if status??&status==4] class="am-active" [/#if] > <a href="javascript:checkType(4)"  >已完成[@order_page status='4' count='3'](${tag_pagination.totalCount})[/@order_page]</a></li>
                    <li  [#if status??&status==3] class="am-active" [/#if] > <a href="javascript:checkType(3)"  >已取消[@order_page  status='3' count='3'](${tag_pagination.totalCount})[/@order_page]</a></li>
                </ul>

                <div class="am-tabs-bd">
                    <div class="am-tab-panel am-fade am-in am-active" id="tab">
                        <div class="am-g am-margin-top">

                            <table class="am-table">


                                [@order_page status=status count='3' code=code userName=userName paymentId=paymentId shippingId=shippingId
                                startTime=startTime endTime=endTime startOrderTotal=startOrderTotal endOrderTotal=endOrderTotal]
                                [#if tag_list?size gt 0]
                                <thead>
                                <th>
                                <td> 商品</td>
                                <td> 订单号</td>
                                <td> 订购日期 </td>
                                <td>  收件人 </td>
                                <td> 支付方式 </td>
                                <td>   配送方式 </td>
                                <td>  订单总计 </td>
                                <td>  可获积分  </td>
                                <td> 订单状态  </td>
                                <td> 订单详情 </td>
                                <td> 操作 </td>
                                </th>
                                </thead>
                                <tbody>
                                [#list tag_list as order]
                                <tr>

                                     <td>
                                         [#list order.items as item]
                                         <dd>
                                             <div class="fr">
                                                 <a class="aBlu againBuy" href="${item.product.url!}" target="_blank">查看详情</a> <br/>
                                             </div>
                                             <a target="_blank" href="${item.product.url}">
                                                 <img src="${item.product.productExt.coverImg!}" height="40" width="40"/></a>
                                             <a class="aGrey" target="_blank" href="${item.product.url}">${item.product.name}</a> <br/>
                                             <em> ¥[#if
                                                 item.productFash??]${item.productFash.salePrice!}[#else]${item.product.salePrice!}[/#if]</em>×
                                             ${item.count}
                                         </dd>
                                         [/#list]
                                     </td>
                                     <td> <a href="myOrderView.htm?orderId=${order.id}" target="_blank">${order.code!}</a></td>
                                    <td>${order.createTime?string('yyyy-MM-dd HH:mm:ss')!}</td>
                                    <td>${order.receiveName!}</td>
                                    <td>${order.payment.name!}</td>
                                    <td>[#if order.shipping??]${order.shipping.name}[/#if]</td>
                                    <td>¥${order.total}</td>
                                    <td>${order.score!0}[#if order.status==20](可用积分)[#else](冻结中)[/#if]</td>
                                    <td>
                                        [#if order.status=3][@s.m "order.status.${order.status}"/][#elseif order.status=4][@s.m
                                        "order.status.${order.status}"/]
                                        [#elseif order.paymentStatus=1][@s.m "order.paymentStatus.${order.paymentStatus}"/]&nbsp;[#if
                                        order.shippingStatus=2][@s.m "order.shippingStatus.${order.shippingStatus}"/][/#if]
                                        [#elseif order.paymentStatus=2][@s.m "order.paymentStatus.${order.paymentStatus}"/]&nbsp;[@s.m
                                        "order.shippingStatus.${order.shippingStatus}"/][/#if]
                                    </td>
                                    <td><a class="aBlu" href="myOrderView.htm?orderId=${order.id}" target="_blank">订单详情</a></td>
                                    <td>
                                        <p><a class="aBlu" href="myOrderView.htm?orderId=${order.id}" target="_blank">订单详情</a></p>
                                        <button class="y90 mr5 orderListAgain" onclick="addCart(${order.id});">再放进购物车</button>
                                        [#if order.status=3]
                                        <button class="w90 payItem netPayButton" onclick="deleteOrder(${order.id});">删除订单</button>
                                        [#elseif order.status=4]
                                        <button class="w90 payItem netPayButton" onclick="deleteOrder(${order.id});">删除订单</button>
                                        [#if !(order.returnOrder??)] <a class="w90 payItem netPayButton"
                                                                        href="../orderReturn/orderReturn.htm?orderId=${order.id}&delivery=1">申请退货</a>[/#if]
                                        [#elseif order.shippingStatus=1]
                                        [#if order.paymentStatus=1]
                                        <button class="w90 payItem netPayButton" onclick="payOrderAgain(${order.id});">立即支付</button>
                                        <button class="w90 payItem netPayButton" onclick="abolishOrder(${order.id});">取消订单</button>
                                        [#elseif order.paymentStatus=2]
                                        [#if !(order.returnOrder??)] <a class="w90 payItem netPayButton"
                                                                        href="../orderReturn/orderReturn.htm?orderId=${order.id}&delivery=0"
                                                                        target="_blank">申请退款</a>[/#if]
                                        [/#if]
                                        [#elseif order.shippingStatus=2]
                                        [#if order.paymentStatus=1]
                                        <button class="w90 payItem netPayButton" onclick="payOrderAgain(${order.id});">立即支付</button>
                                        [#elseif order.paymentStatus=2]
                                        <button class="w90 payItem netPayButton" onclick="accomplishOrder(${order.id});">确认收货</button>
                                        [/#if]
                                        [/#if]
                                    </td>
                                  </tr>
                                [/#list]
                                <div align="center">[@pagination_style sysPage='1'/]</div>
                                [#else]
                                <div>暂无订单 ，这就去<a href="${base}/" target="_self">商城</a>挑选商品。</div>
                                [/#if]
                                [/@order_page]
                                </tbody>


                            </table>

                         </div>
                    </div>

                </div></div>
            </div>
        </form>
       </div>

    </div>
    <div class="clear"></div>
</div>
</div>
[#include "../include/footer.html"/]
</body>
</html>
